package com.airconditioner.sales.activity;

import android.content.Intent;
import android.os.Handler;

import com.airconditioner.sales.R;
import com.airconditioner.sales.service.IntentService;
import com.airconditioner.sales.service.PushService;
import com.airconditioner.sales.util.ShareP;
import com.airconditioner.sales.util.StringUtil;
import com.igexin.sdk.PushManager;

import org.xutils.view.annotation.ContentView;

@ContentView(R.layout.activity_main)
public class MainActivity extends BaseActivity {

    @Override
    public void init() {
        super.init();
        initGeTui();
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                Class cls;
                Intent intent = new Intent();
                if (StringUtil.isNotBlank(ShareP.getUserId(context)))
                    cls = HomeActivity.class;
                else
                    cls = WxLoginActivity.class;
                intent.setClass(MainActivity.this, cls);
                startActivity(intent);
                finish();
            }
        }, 2000);
    }

    private void initGeTui() {
        // PushService 为第三方自定义推送服务
        PushManager.getInstance().initialize(this.getApplicationContext(), PushService.class);
        // IntentService 为第三方自定义的推送服务事件接收类
        PushManager.getInstance().registerPushIntentService(this.getApplicationContext(), IntentService.class);
    }
}
